<template>
  <div class="home">
    <div class="nav-title">
      <div class="nav-wrap">
        <img src="../assets/logo.png" alt />
        <h2 class="titles">电商后台管理系统</h2>
        <router-link to="/">
          <a href="#" class="Signout">退出</a>
        </router-link>
      </div>
    </div>
    <div class="con-left">
      <el-menu class="el-menu-vertical-demo" style="border:0;" unique-opened >
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span class="titles">用户管理</span>
          </template>
          <router-link to="/Users">
            <el-menu-item index="1-1">
              <i class="el-icon-menu"></i>
              用户列表
            </el-menu-item>
          </router-link>
        </el-submenu>
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>权限管理</span>
          </template>
          <router-link to="/Roles">
            <el-menu-item index="2-1">
              <i class="el-icon-menu"></i>
              角色列表
            </el-menu-item>
          </router-link>
          <router-link to="/Power">
            <el-menu-item index="2-2">
              <i class="el-icon-menu"></i>
              权限列表
            </el-menu-item>
          </router-link>
        </el-submenu>

        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>商品管理</span>
          </template>
          <router-link to="/Good">
            <el-menu-item index="3-1">
              <i class="el-icon-menu"></i>
              商品列表
            </el-menu-item>
          </router-link>
          <router-link to="/Param">
            <el-menu-item index="3-2">
              <i class="el-icon-menu"></i>
              分类参数
            </el-menu-item>
          </router-link>
          <router-link to="/Power">
            <el-menu-item index="3-3">
              <i class="el-icon-menu"></i>
              商品分类
            </el-menu-item>
          </router-link>
        </el-submenu>
        <el-submenu index="4">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span class="titles">订单管理</span>
          </template>
          <router-link to="/Users">
            <el-menu-item index="4-1">
              <i class="el-icon-menu"></i>
              订单列表
            </el-menu-item>
          </router-link>
        </el-submenu>
        <el-submenu index="5">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span class="titles">数据统计</span>
          </template>
          <router-link to="/Users">
            <el-menu-item index="5-1">
              <i class="el-icon-menu"></i>
              数据列表
            </el-menu-item>
          </router-link>
        </el-submenu>
      </el-menu>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menus: [],
      conHeight: 0
    };
  },
  methods: {
    //加载权限菜单
    loadMenus() {
      this.$http("menus", {}, "get").then(res => {
        this.menus = res.data;
      });
    }
  },
  created() {
    this.conHeight = window.innerHeight + "px";
    this.loadMenus();
    this.$nextTick(() => {
      window.addEventListener("resize", () => {
        this.conHeight = window.innerHeight + "px";
      });
    });
  },
  computed: {
    activeIndex() {
      return "/" + this.$route.matched[0].path.split("/")[1];
    }
  },
  mounted() {}
};
</script>

<style scoped lang="scss">
.home {
  width: 100%;
  height: 100%;
  position: fixed;
  background: rgb(233, 238, 243);
}
.nav-title {
  width: 100%;
  height: 60px;
  background: #b3c0d1;
  position: fixed;
  top: 0;
  left: 0;
}
.nav-wrap {
  width: 1496px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .titles {
    color: #fff;
    // text-align: center;
  }
  .Signout {
    width: 63px;
    display: inline-block;
  }
}
.con-left {
  width: 199px;
  height: 100%;
  background-color: #fff;
  border-right: 1px solid #e6e6e6;
  position: fixed;
  left: 0;
  top: 60px;
  z-index: 99;
  .icon {
    vertical-align: middle;
    margin-right: 7px;
    text-align: center;
    font-size: 20px;
    color: #909399;
  }
  .titles {
    font-size: 14px;
    color: #303133;
  }
  .el-submenu .el-menu-item {
    min-width: 180px;
  }
}
</style>
